/*
 * TCSS 360 - Winter 2014
 * TESK Software
 */
package view.userProfile;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import java.awt.GridLayout;

import javax.swing.JLabel;

import Content.ProjectModel;

import com.jgoodies.forms.factories.DefaultComponentFactory;

import java.awt.Font;
import java.awt.Color;

import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.SwingConstants;

import view.LogInView;
import view.MainFrame;
import view.SelectConferenceForRecommendation;
import view.SelectConferenceSubChair;
import view.Papers.ReviewerListView;
import view.Papers.SubmitRecommendationView;

import java.awt.FlowLayout;
import javax.swing.border.MatteBorder;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;

/**
 * The view for a sub program chair.
 * 
 * @author Kon
 * @version March 7, 2014
 */
public class SubProgramChairView extends JPanel{

	private static final long serialVersionUID = 1L;
	
	/** The current panel to be used to pass to new panels. */
	private final JPanel my_panel;
	
	/** The frame the panel is associated with. */
	private final MainFrame my_frame;
	
	/**
	 * Constructs a view for the sub program chair.
	 * @param the_frame the frame the panel is to be associated with
	 */
	public SubProgramChairView(final MainFrame the_frame) {
		my_frame = the_frame;
		my_panel = this;
		setLayout(new GridLayout(3, 1, 0, 0));
		init();
		
	}
	
	/**
	 * Adds specifications and components to the panel.
	 */
	private void init() {
		JPanel headerPanel = new JPanel();
		headerPanel.setBorder(new BevelBorder(BevelBorder.RAISED, new Color(255, 105, 180), new Color(127, 255, 212), new Color(210, 105, 30), new Color(124, 252, 0)));
		headerPanel.setBackground(Color.WHITE);
		add(headerPanel);
		headerPanel.setLayout(null);
			
		
		
		ImageIcon icon = new ImageIcon(getClass().getResource("/cait.jpg"));
		final JLabel pic = new JLabel();
		pic.setSize(150, 130);
		pic.setLocation(30, 10);
		//pic.setIcon(new ImageIcon("..\\Conference System\\src\\cait.jpg"));
		pic.setIcon(icon);
		JLabel lblNewJgoodiesLabel = DefaultComponentFactory.getInstance().createLabel("Welcome, SubProgram Chair!");
		lblNewJgoodiesLabel.setBounds(177, 37, 251, 31);
		lblNewJgoodiesLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewJgoodiesLabel.setForeground(Color.DARK_GRAY);
		lblNewJgoodiesLabel.setFont(new Font("Urdu Typesetting", Font.PLAIN, 18));
		
		headerPanel.add(pic);
		headerPanel.add(lblNewJgoodiesLabel);
		
		JPanel baseBotPanel = new JPanel();
		baseBotPanel.setBorder(new MatteBorder(1, 4, 1, 4, (Color) new Color(255, 105, 180)));
		baseBotPanel.setBackground(new Color(240, 255, 255));
		FlowLayout flowLayout_1 = (FlowLayout) baseBotPanel.getLayout();
		flowLayout_1.setVgap(20);
		add(baseBotPanel);
		
		JPanel buttonPanel = new JPanel();
		baseBotPanel.add(buttonPanel);
		buttonPanel.setLayout(new GridLayout(4, 1, 0, 0));

		final JButton assignPaperButton = new JButton("Assign Papers to Reviewers");
		assignPaperButton.setBackground(UIManager.getColor("Button.background"));
		assignPaperButton.setForeground(new Color(75, 0, 130));
		assignPaperButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				my_frame.setNewPanel(new SelectConferenceSubChair(my_frame, my_panel));
			}
		});
		
		JButton btnNewButton = new JButton("Reviewer List");
		btnNewButton.setBackground(UIManager.getColor("Button.background"));
		btnNewButton.setForeground(new Color(75, 0, 130));
		buttonPanel.add(btnNewButton);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ReviewerListView rev = new ReviewerListView(my_frame);
				my_frame.setNewPanel(rev);
			}
		});
		buttonPanel.add(assignPaperButton);
		
		
		//log out
		final JButton logOut = new  JButton("Log Out");
		logOut.setBackground(UIManager.getColor("Button.background"));
		logOut.setForeground(new Color(75, 0, 130));
		logOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				 ProjectModel model = new ProjectModel();
				JPanel view = new LogInView(my_frame);
				my_frame.setNewPanel(view);
			}
		});
		
		JButton btnSubmitRecommendation = new JButton("Submit Recommendation");
		btnSubmitRecommendation.setBackground(UIManager.getColor("Button.background"));
		btnSubmitRecommendation.setForeground(new Color(75, 0, 130));
		buttonPanel.add(btnSubmitRecommendation);
		btnSubmitRecommendation.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				SelectConferenceForRecommendation panel = new SelectConferenceForRecommendation(my_frame, my_panel);
				my_frame.setNewPanel(panel);
				my_frame.revalidate();
				my_frame.repaint();
			}
		});
		buttonPanel.add(logOut);
		
		
		JPanel southPanel = new JPanel();
		southPanel.setBackground(Color.WHITE);
		add(southPanel);
		southPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		ImageIcon icon1 = new ImageIcon(getClass().getResource("/stripe.gif"));
		final JLabel pic1 = new JLabel();
		//stripe.setIcon(new ImageIcon("..\\Conference System\\src\\stripe.gif"));
		pic1.setIcon(icon1);
		southPanel.add(pic1);
		
	
	}
}
